import Mock from 'mockjs'
//只能用正则来匹配
const id = 'admin'
const pwd = 'admin'
const list = Mock.mock({
  "result|100": [
    {
      'id|+1': 1,
      'menuid': /[A-Z][a-z][a-z][a-z][a-z]/,
      'menuname|1': ['系统管理', '公司管理', '机构菜单管理', '机构类型管理', '机构角色管理', '系统操作员', '产品列表'],
      'menutype': '交易商',
      'menuurl': /[A-Z][a-z][a-z][a-z][a-z]/,
      'menulevel|1': ["一级菜单", '二级菜单', '三级菜单'],
      'menuparentid': /[A-Z][a-z][a-z][a-z][a-z]/,
      'menuparentname|1': ['系统管理', '公司管理', '机构菜单管理', '机构类型管理', '机构角色管理', '系统操作员', '产品列表'],
    }
  ]
})
console.log(list);
Mock.mock(RegExp(/\/userLogin/), 'post', function (options) {
  let effectRows
  let body = JSON.parse(options.body)
  if (body.id == id && body.pwd == pwd) {
    effectRows = 1
  } else {
    effectRows = 0
  }
  return { effectRows }
})
Mock.mock(RegExp(/\/menuinfo/), 'get', function (options) {
  return [
    {
      name: "首页",
      icon: "el-icon-price-tag",
      router: 'admin'
    },
    {
      name: "机构权限管理",
      icon: "el-icon-office-building",
      child: [
        { name: "机构菜单管理", router: 'office-1' },
        { name: "机构角色管理", router: 'office-2' }
      ]
    },
    {
      name: "系统操作员用户管理",
      icon: "el-icon-user",
      router: 'user'
    },
    {
      name: "产品管理",
      icon: "el-icon-copy-document",
      child: [
        { name: "产品分类管理", router: 'copy-1' },
        { name: "产品列表", router: 'copy-2' }
      ]
    },
    {
      name: "公司管理",
      icon: "el-icon-folder",
      router: 'folder'
    },
    {
      name: "客户管理",
      icon: "el-icon-coordinate",
      child: [
        { name: "投资客户账号管理", router: 'coordinate-1' },
        { name: "客户账号列表", router: 'coordinate-2' },
        { name: "客户组列表", router: 'coordinate-3' }
      ]
    },
    {
      name: "客户消息中心",
      icon: "el-icon-chat-dot-square",
      child: [
        { name: "客户消息模板配置", router: 'chat-1' },
        { name: "客户消息列表", router: 'chat-2' }
      ]
    },
    {
      name: "交易管理",
      icon: "el-icon-connection",
      child: [
        { name: "订单列表", router: 'connection-1' },
        { name: "成交记录列表", router: 'connection-2' },
        { name: "仓位列表", router: 'connection-3' }
      ]
    }
  ]
})
Mock.mock(RegExp(/\/getHome/), 'get', function () {
  return {
    info: {
      name: "御金汇公司",
      detail: "公司负责东南亚市场, 分管黑马证券、传智证券",
      list: [
        { num: 3, info: "下属公司" },
        { num: 12, info: "系统操作员" },
      ],
    },
    daiban: {
      icon: "el-icon-document-checked",
      title: "待办信息",
      list: [
        {
          title: "客户管理",
          item: [
            { num: 3, info: "销户待办" },
            { num: 12, info: "转组待办" },
          ],
        },
        {
          title: "系统用户管理",
          item: [
            { num: 3, info: "密码重置待办" },
            { num: 12, info: "待办名称" },
          ],
        },
      ],
    },
    prolist: {
      icon: "el-icon-coin",
      title: "订单统计列表",
    },
    adinfo: {
      icon: "el-icon-document-copy",
      title: "公司运营报表",
    },
    message: {
      icon: "el-icon-chat-round",
      title: "消息/通知",
      list: [
        {
          msg: "成交通知",
          time: "2019-10-01",
        },
        {
          msg: "用户注册通知",
          time: "2019-10-01",
        },
        {
          msg: "产品下架通知",
          time: "2019-10-01",
        },
      ],
    },
    sysmsg: {
      icon: "el-icon-set-up",
      title: "系统公告",
      list: [
        {
          msg: "机构调整公告",
        },
        {
          msg: "系统升级公告",
        },
        {
          msg: "日志更新公告",
        },
      ],
    },
    syshelp: {
      icon: "el-icon-cpu",
      title: "系统帮助",
      list: [
        {
          msg: "帮助手册v3.0",
        },
        {
          msg: "帮助手册v2.0",
        },
        {
          msg: "帮助手册v1.0",
        },
      ],
    },
    shoplist: [
      { value: 234, name: '撤单' },
      { value: 335, name: '待成交' },
      { value: 310, name: '部分成交' },
      { value: 234, name: '完成成交' },
    ],
    comlist: {
      data: ['2021年1月', '2021年2月', '2021年3月', '2021年4月', '2021年5月', '2021年6月'],
      value: [5, 20, 36, 10, 10, 20],
      options: [
        {
          value: '选项1',
          label: '平台盈利',
        },
      ]
    },

  }
})
Mock.mock(RegExp(/\/getjgmenu/), 'get', function (options) {
  return list
})